//
//  YSCommentMsgView.m
//  Yueshi
//
//  Created by yueshi－mac1 on 15/12/7.
//  Copyright © 2015年 悦食中国. All rights reserved.
//

#import "YSCommentMsgView.h"

@interface YSCommentMsgView()
@property (strong, nonatomic) UILabel *postNameLabel;
@property (strong, nonatomic) UIImageView *avatarView;
@property (strong, nonatomic) UILabel *userNameLabel;
@property (strong, nonatomic) UILabel *timeLabel;
@property (strong, nonatomic) UILabel *contentLabel;
@property (strong, nonatomic) UIView *spliteView;
@end

@implementation YSCommentMsgView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        UILabel *postNameLabel = [[UILabel alloc] init];
        [postNameLabel setFont:SYS_FONT(postNameFont)];
        [postNameLabel setTextColor:publicTextColor];
        [self addSubview:postNameLabel];
        _postNameLabel = postNameLabel;
        
        UIImageView *avatarView = [[UIImageView alloc]init];
        avatarView.clipsToBounds = YES;
        avatarView.layer.masksToBounds = YES;
        avatarView.layer.cornerRadius = 100/4;
        [avatarView setSize:CGSizeMake(100/2, 100/2)];
        [self addSubview:avatarView];
        _avatarView = avatarView;
        
        UILabel *userNameLabel = [[UILabel alloc] init];
        [userNameLabel setFont:SYS_FONT(15)];
        [userNameLabel setTextColor:publicTextColor];
        [self addSubview:userNameLabel];
        _userNameLabel = userNameLabel;
        
        UILabel *timeLabel = [[UILabel alloc] init];
        [timeLabel setFont:SYS_FONT(13)];
        [timeLabel setTextColor:HEXColor(@"#9e9e9e")];
        [self addSubview:timeLabel];
        _timeLabel = timeLabel;
        
        UILabel *contentLabel = [[UILabel alloc] init];
        [contentLabel setFont:SYS_FONT(14)];
        [contentLabel setTextColor:HEXColor(@"#9e9e9e")];
        [self addSubview:contentLabel];
        _contentLabel = contentLabel;
        
        UIView *spliteView = [[UIView alloc]init];
        [spliteView setBackgroundColor:PUBLIC_BG];
        [self addSubview:spliteView];
        _spliteView = spliteView;

    }
    return self;
}

- (void)setCommentMsgFrame:(YSCommentMsgFrame *)commentMsgFrame{
    _commentMsgFrame = commentMsgFrame;
    YSCommentMsg *commentMsg = commentMsgFrame.commentMsg;
    
    _postNameLabel.text = commentMsg.postName;
    _postNameLabel.frame = commentMsgFrame.postNameFrame;
    
    _avatarView.x = commentMsgFrame.avatarFrame.origin.x;
    _avatarView.y = commentMsgFrame.avatarFrame.origin.y;
    [_avatarView setImageURLStr:commentMsg.headImage];
    
    _userNameLabel.text = commentMsg.commentName;
    _userNameLabel.frame = commentMsgFrame.userNameFrame;
    
    _timeLabel.text = commentMsg.commentTime;
    _timeLabel.frame = commentMsgFrame.timeFrame;
    
    _contentLabel.frame = commentMsgFrame.contentFrame;
    _contentLabel.text = commentMsg.commentContent;
    
    _spliteView.frame = commentMsgFrame.spliteFrame;
    
    self.frame = commentMsgFrame.frame;
}

@end
